<?php

namespace addons\hlapp\controller;

use addons\hlapp\dto\Result;
use addons\hlapp\model\HlappArea;
use addons\hlapp\model\HlappMember;
use addons\hlapp\model\HlappPart;
use addons\hlapp\model\HlappProject;
use addons\hlapp\model\HlappProjectEvaluate;
use addons\hlapp\model\HlappProjectStatus;
use think\Db;

class Area extends Common
{
    public $adminLogin = true;//注意：因为这是后台业务菜单所以需要管理员登录操作的
    public $pageSize = 10;

//-------------
//---- 页面
//-------------
    /**
     * 列表页
     */
    public function areaList()
    {
        $list = (new HlappArea())->with('engineer,manager')->select();
        $this->assign("list", $list);
        return $this->fetch();
    }

    /**
     * 编辑页面
     */
    public function updatePage()
    {
        $area = (new HlappArea())->find($_GET['id']);
        $managers = (new HlappMember())->where('partId',6)->select();
        $engineers = (new HlappMember())->where('partId',7)->select();

        $this->assign("area", $area);
        $this->assign("engineers", $engineers);
        $this->assign("managers", $managers);
        return $this->fetch();
    }
    /**
     * 添加页面
     */
    public function addPage(){
        $managers = (new HlappMember())->where('partId',6)->select();
        $engineers = (new HlappMember())->where('partId',7)->select();
        $this->assign("engineers", $engineers);
        $this->assign("managers", $managers);
        return $this->fetch();
    }

    /**
     * 添加方法
     * @return false|string
     */
    public function add(){
        $id = (new HlappArea())->saveOrUpdata($_POST);
        if ($id > 0){
            $r = Result::getOk();
        }else{
            $r = Result::getError();
        }
        return $r;
    }

    /**
     * 更新接口
     */
    public function update(){
        $id = (new HlappArea())->saveOrUpdata($_POST);
        if ($id > 0){
            $r = Result::getOk();
        }else{
            $r = Result::getError();
        }
        return $r;
    }

}